{[{define "system/appi/edit.html" }]}
<style>
    .layui-iconpicker-body.layui-iconpicker-body-page .hide {
        display: none;
    }
</style>
<link rel="stylesheet" href="/static/admin/css/public.css" media="all">
<link rel="stylesheet" href="/static/plugs/layui-v2.5.6/css/layui.css" media="all">
<link rel="stylesheet" href="/static/plugs/lay-module/autocomplete/autocomplete.css" media="all">
<link rel="stylesheet" href="/static/plugs/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <input type="hidden" name="id" value="{[{.item.Id}]}">

        <div class="layui-form-item  layui-row layui-col-xs12">
            <label class="layui-form-label required">上级菜单</label>
            <div class="layui-input-block">
                <select name="pid">
                    {[{ $id := .item.Pid }]}
                    {[{ range .list }]}
                    <option value="{[{.Id}]}"
                            {[{if eq  .Id $id}]}
                                selected
                            {[{end}]}>
                    {[{.Title}]}
                    </option>
                    {[{ end }]}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">菜单名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" class="layui-input" lay-verify="required" lay-reqtext="请输入菜单名称" placeholder="请输入菜单名称" value="{[{.item.Title}]}">
                <tip>填写菜单名称。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">菜单链接</label>
            <div class="layui-input-block">
                <input type="text" id="href" name="url" class="layui-input" lay-reqtext="请输入菜单链接" placeholder="请输入菜单链接" value="{[{.item.Href }]}">
                <tip>填写菜单链接。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">提交方式</label>
            <div class="layui-input-block">

                <input type="radio" name="method" value="get" title="get" {[{if eq .item.Method "get" }]}checked{[{end}]}>
                <input type="radio" name="method" value="post" title="post" {[{if eq .item.Method "post" }]}checked{[{end}]}>

            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">选择图标</label>
            <div class="layui-input-block">
                <input type="text" id="icon" name="icon" lay-filter="icon" class="hide"  value="{[{.item.Icon }]}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">target属性</label>
            <div class="layui-input-block">
                <input type="radio" name="target" value="_self" title="_self" {[{if eq .item.Target "_self" }]}checked{[{end}]}>
                <input type="radio" name="target" value="_blank" title="_blank" {[{if eq .item.Target "_blank" }]}checked{[{end}]}>
                <input type="radio" name="target" value="_parent" title="_parent" {[{if eq .item.Target "_parent" }]}checked{[{end}]}>
                <input type="radio" name="target" value="_top" title="_top" {[{if eq .item.Target "_top" }]}checked{[{end}]}>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">应用验证</label>
            <div class="layui-input-block">
                <input type="radio" name="isappid" value="1" title="是" {[{if eq .item.Isappid 1 }]}checked{[{end}]}>
                <input type="radio" name="isappid" value="0" title="否" {[{if eq .item.Isappid 0 }]}checked{[{end}]}>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否登录</label>
            <div class="layui-input-block">

                <input type="radio" name="islogin" value="1" title="是" {[{if eq .item.Islogin 1 }]}checked{[{end}]}>
                <input type="radio" name="islogin" value="0" title="否" {[{if eq .item.Islogin 0 }]}checked{[{end}]}>

            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block">

                <input type="radio" name="type" value="0" title="链接" {[{if eq .item.Type 0 }]}checked{[{end}]}>
                <input type="radio" name="type" value="1" title="菜单" {[{if eq .item.Type 1 }]}checked{[{end}]}>
                <input type="radio" name="type" value="2" title="目录" {[{if eq .item.Type 2 }]}checked{[{end}]}>

            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">菜单排序</label>
            <div class="layui-input-block">
                <input type="number" name="px" lay-reqtext="菜单排序不能为空" placeholder="请输入菜单排序" value="{[{ .item.Px }]}" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="memo" class="layui-textarea" placeholder="请输入备注信息">{[{.item.Memo}]}</textarea>
            </div>
        </div>

        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="add">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script src="/static/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/static/layuimini/js/lay-config.js" charset="utf-8"></script>
<script>

    layui.use(['form', 'jquery','iconPickerFa','sh'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            iconPickerFa = layui.iconPickerFa,
            sh = layui.sh;


        iconPickerFa.render({
            elem: '#icon',
            url: '/static/plugs/font-awesome-4.7.0/less/variables.less',
            limit: 12,
            click: function (data) {
                $('#icon').val('fa ' + data.icon);
            },
            success: function (d) {
                console.log(d);
            }
        });

        form.on('submit(add)', function (data) {
            data = data.field;
            sh.request.post(
                {
                    url: '/system/appi/edit_ajax',
                    data: data,
                }, function (res) {
                    console.log(res)
                    if (res.code == 200) {
                        sh.msg.success('修改成功', function () {
                            window.parent.location.reload();//刷新父页面
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        });
                    } else {
                        sh.msg.error(data.msg, {icon: 2});
                    }
                }
            );
            return false;
        });
    });



</script>
{[{end}]}